/** @Date 下午6:20:32
  * @version 1.0.0
  * @author shangyd
  * Copyright (c) 2015
  */
package com.sdw.soft.test.jse;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

import sun.misc.ProxyGenerator;
public class DynamicProxy {

	public static void main(String[] args) throws Exception{
		byte[] proxy = ProxyGenerator.generateProxyClass("$Proxy1",new Class[]{IUser.class});
		ByteArrayInputStream bais = new ByteArrayInputStream(proxy);
		FileOutputStream fos = new FileOutputStream(new File("D:/$Proxy1.class"));
		int n = 0;
		byte[] b = new byte[1024];
		while((n= bais.read(b)) != -1){
			fos.write(b,0,n);
		}
		if(fos  != null){
			fos.close();
		}
		if(bais != null){
			bais.close();
		}
	}
}
